﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RestaurateurConsole
{
    public class ABill
    {
        public string Item { get; set; }
        public decimal Quantity { get; set; }
        public decimal Price { get; set; }
        public decimal Amount { get; set; }
        public string OtherItem { get; set; }
    }

    class PerTableBill
    {
        private int tableNo;
        private bool isSaved = false;
        private decimal totalWithoutTax = (decimal)0;
        private decimal tax = (decimal)0;
        private decimal totalWithTax = (decimal)0;

        List<ABill> bill = new List<ABill>();
        List<int> dirtySoldItemIDs = new List<int>();

        public List<int> DirtySoldItemIDs
        {
            get
            {
                return dirtySoldItemIDs;
            }
        }

        private PerTableBill() { }
        public PerTableBill(int TableNo) { tableNo = TableNo; BillDate = DateTime.Now; }

        public string Account { get; set; }
        public decimal Amount { get; set; }
        public DateTime BillDate { get; set; }
        public int BillNo { get; set; }

        public List<ABill> Bill
        {
            get
            {
                return bill;
            }
        }

        public int NoOfItems { get; set; }

        public decimal TotalWithoutTax
        {
            get
            {
                return totalWithoutTax;
            }
            set
            {
                totalWithoutTax = value;
                if (totalWithoutTax > ConfigHandler.Configuration.TaxAdditionThreshhold)
                    tax = (ConfigHandler.Configuration.TaxRate * totalWithoutTax / (decimal)100);
                totalWithTax = totalWithoutTax + tax;
            }
        }

        public decimal Tax { get { return tax; } }
        public decimal TotalWithTax { get { return totalWithTax; } }

        public bool IsSaved
        {
            get
            {
                return isSaved;
            }
            set
            {
                isSaved = value;
            }
        }
    }
}
